<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class M_college extends CI_Model {
    /**
     * 继承父类
     */
    function __construct()
    {
        parent::__construct();
    }
    /**
     * 学院列表
     * @return [type] [description]
     */
    public function getAcademy(){
        $query="SELECT * FROM stu_college WHERE p_id='0'";
        $result=$this->db->query($query);
        return $result->result();
    }
    /**
     * 相关学院的专业列表
     * @param  [type] $p_id [description]
     * @return [type]       [description]
     */
    public function getMajor($p_id){
        $query="SELECT * FROM stu_college WHERE p_id='".$p_id."'";
        $result=$this->db->query($query);
        return $result->result();
    }
    /**
     * 查找学院或专业信息
     * @param  [type] $id [description]
     * @return [type]     [description]
     */
    public function getNumber($id){
        $query="SELECT * FROM stu_college WHERE co_id='".$id."'";
        $result=$this->db->query($query);
        return $result->result();
    }
    /**
     * 获取学院
     * @param  [type] $str [description]
     * @return [type]      [description]
     */
    public function academy($str){
        $where='';
        foreach ($str as $key => $value) {
            $where.=$where?(" AND ".$key."='".$value."'"):($key."='".$value."'");
        }
        $query="SELECT * FROM stu_college WHERE ".$where;
        $result=$this->db->query($query);
        return $result->result();
    }
}